package com.bocai.eelly.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.bocai.eelly.R;
import com.bocai.eelly.bean.OrderListBean;
import com.bocai.eelly.utils.TimeUtils;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by admin on 2016/5/30.
 */
public class FindOrderAdp extends BaseAdapter {
    private Context context;
    private List<OrderListBean.Data> datas;
    public FindOrderAdp(Context context,List<OrderListBean.Data> datas) {
        this.context = context;
        this.datas=datas;
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.find_order_item, null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.tvFindOrderNum.setText("订单数量："+datas.get(position).getNum()+"件");
        viewHolder.tvFindOrderName.setText(datas.get(position).getStyle());
        viewHolder.tvFindOrderMaterial.setText(datas.get(position).getFabric_name());
        viewHolder.tvFindOrderTime.setText("交货期"+TimeUtils.getMonth(Long.parseLong(datas.get(position).getHandle_time())));
        viewHolder.tvFindOrderCity.setText(datas.get(position).getCity());
        return convertView;
    }



    class ViewHolder {
        @Bind(R.id.tv_find_order_num)
        TextView tvFindOrderNum;
        @Bind(R.id.tv_find_order_name_title)
        TextView tvFindOrderNameTitle;
        @Bind(R.id.tv_find_order_name)
        TextView tvFindOrderName;
        @Bind(R.id.tv_find_order_material_title)
        TextView tvFindOrderMaterialTitle;
        @Bind(R.id.tv_find_order_material)
        TextView tvFindOrderMaterial;
        @Bind(R.id.tv_find_order_time)
        TextView tvFindOrderTime;
        @Bind(R.id.tv_find_order_city)
        TextView tvFindOrderCity;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
